package com.itheima.day03;
/*
案例7:使用Random生成随机数
    猜数字.
 */


import java.util.Random;
import java.util.Scanner;
import java.util.jar.JarOutputStream;

public class TestClassCase07 {

    public static void main(String[] args) {
/*

        //创建random scanner 对象

        Random r=new Random();
        Scanner sc=new Scanner(System.in);


        int guessNum=r.nextInt(100)+1;

        while(true){

            System.out.println("请输入你的猜测:");
            int youNum=sc.nextInt();

            if(youNum > guessNum){
                System.out.println("猜大了");
            }
            else if(youNum<guessNum){
                System.out.println("猜小了");
            }else{
                System.out.println("恭喜您成功了!!");
                break;
            }

        }
*/

//  猜数字游戏

        Random num=new Random();
        Scanner sc=new Scanner(System.in);

        int a=num.nextInt(100)+1;
        System.out.println(a);


        while(true){

            System.out.println("请输入:");
            int b=sc.nextInt();
            if (a>b){
                System.out.println("你输小了!");
            }
            else if (a<b){
                System.out.println("你输大了!");
            }else{
                System.out.println("恭喜你,赢了!!");
                break;
            }
        }


    }


}
